package logic

import (
	"activity_srv/activity"
	"activity_srv/internal/svc"
	"activity_srv/model"
	"context"
	"go.uber.org/zap"
	"smart-health-platforms/pkg"

	"github.com/zeromicro/go-zero/core/logx"
)

type BargainUserListLogic struct {
	ctx    context.Context
	svcCtx *svc.ServiceContext
	logx.Logger
}

func NewBargainUserListLogic(ctx context.Context, svcCtx *svc.ServiceContext) *BargainUserListLogic {
	return &BargainUserListLogic{
		ctx:    ctx,
		svcCtx: svcCtx,
		Logger: logx.WithContext(ctx),
	}
}

// 我的砍价
func (l *BargainUserListLogic) BargainUserList(in *activity.BargainUserListRequest) (*activity.BargainUserListResponse, error) {
	var ba model.BargainActivity
	ba.UserId = int32(in.UserId)
	list, err := ba.BargainList()
	if err != nil {
		pkg.Error("失败", zap.Error(err))
		return nil, err
	}
	var baList []*activity.BargainUserList
	for _, bargainActivity := range list {
		baList = append(baList, &activity.BargainUserList{
			SkuId:  int64(bargainActivity.SkrId),
			Status: int64(bargainActivity.Status),
		})
	}
	return &activity.BargainUserListResponse{
		List: baList,
	}, nil
}
